package com.sbj.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sbj.dto.res.BankRes;
import com.sbj.entity.Bank;
import com.sbj.mapper.BankMapper;
import com.sbj.service.IBankService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author summer
 * @since 2024/08/10 10:02:39
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class BankServiceImpl extends ServiceImpl<BankMapper, Bank> implements IBankService {

    @Override
    public List<BankRes> bankList() {
        LambdaQueryWrapper<Bank> eq = Wrappers.lambdaQuery(Bank.class).eq(Bank::getMemberId, StpUtil.getLoginIdAsInt());
        return Convert.toList(BankRes.class,this.list(eq));
    }
}
